

/**
 * 
 * @param {判断是不是黑白棋} player 
 * @param {当前下的位置} site 
 * @returns 
 */
 export function algs(player) {
  const zus=this.state.axis.slice();


 if (as(zus,player,0,1)) {
    return true;
 } else if(as(zus,player,1,0)) {
    return true;
 }else if(as(zus,player,1,1)){
    return true;
 }else if(as(zus,player,-1,1)){
    return true;
 }else{
    return false;
 }

}

/**
 * 
 * @param {所有的棋子} zus 
 * @param {当前的棋子位置} w  { "isHea": isHea, "x": x, "y": y }
 * @param {*} xfil 
 * @param {*} yfil 
 */
function as(zus,w, xfil,yfil){
   
  let cenn=0;
  for(let i=1 ;i < 5;i++){
    let x=w.x -xfil*i;
    let y=w.y -yfil*i;
    let v={ "isHea": w.isHea, "x": x, "y": y }
     if(!(zut(zus,v))){
        break;
     }
    cenn++;
  }

  
  for(let i=1 ;i < 5;i++){
    let x=w.x +xfil*i;
    let y=w.y +yfil*i;
    let v={ "isHea": w.isHea, "x": x, "y": y }
     if(!(zut(zus,v))){
        break;
     }
    cenn++
  }
 if(cenn>=4){
   return true;
 }else{
   return false;
 }


}
function zut(a,b ){
   let det=false;

let i=a.length;

for(let t =0;t<i; t++){

   if(a[t] !=null){
      let a1=a[t].isHea;
      let a2= a[t].x;
      let a3= a[t].y;
      let b1=b.isHea;
      let b2= b.x;
      let b3= b.y;
      if(a1===b1&& a2===b2&& a3===b3){
         det= true;
         break;
      }

}}

return det;
}
 


